<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="../../../../lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.useso.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="../../../../lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="../../../../css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="../../../../images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="../../../../images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="../../../../images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="../../../../images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Java,jdk,tomcat," />










<meta name="description" content="安装JDK(配置java环境)： 环境：CentOS6.5_x86-64bit 一、先安装JVM 1.使用7版本的jdk(到官网下载相应的软件包到本地http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jre-7u9-oth-JPR) [root@l">
<meta name="keywords" content="Java,jdk,tomcat">
<meta property="og:type" content="article">
<meta property="og:title" content="Tomcat环境搭建及jsp站点实现">
<meta property="og:url" content="http://demo_demo.gitee.io/2014/08/28/tomcat-e7-8e-af-e5-a2-83-e6-90-ad-e5-bb-ba-e5-8f-8ajsp-e7-ab-99-e7-82-b9-e5-ae-9e-e7-8e-b0/index.html">
<meta property="og:site_name" content="运维人">
<meta property="og:description" content="安装JDK(配置java环境)： 环境：CentOS6.5_x86-64bit 一、先安装JVM 1.使用7版本的jdk(到官网下载相应的软件包到本地http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jre-7u9-oth-JPR) [root@l">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/wpid-d698a595a631e5b1f4c10780198b6dc9_c8b5d927-ed11-4825-ac80-c5f047b7c4a0-600x348.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat.png">
<meta property="og:image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat1.png">
<meta property="og:image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat2.png">
<meta property="og:image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat3.png">
<meta property="og:image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat4.png">
<meta property="og:image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat5.png">
<meta property="og:updated_time" content="2018-12-10T10:49:03.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Tomcat环境搭建及jsp站点实现">
<meta name="twitter:description" content="安装JDK(配置java环境)： 环境：CentOS6.5_x86-64bit 一、先安装JVM 1.使用7版本的jdk(到官网下载相应的软件包到本地http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jre-7u9-oth-JPR) [root@l">
<meta name="twitter:image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/wpid-d698a595a631e5b1f4c10780198b6dc9_c8b5d927-ed11-4825-ac80-c5f047b7c4a0-600x348.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://demo_demo.gitee.io/2014/08/28/tomcat-e7-8e-af-e5-a2-83-e6-90-ad-e5-bb-ba-e5-8f-8ajsp-e7-ab-99-e7-82-b9-e5-ae-9e-e7-8e-b0/"/>





  <title>Tomcat环境搭建及jsp站点实现 | 运维人</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
<a href="https://github.com/guomaoqiu" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#FD6C6C; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">运维人</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">生命在于折腾</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://demo_demo.gitee.io">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="OutMan">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/myphoto.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="运维人">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Tomcat环境搭建及jsp站点实现</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2014-08-28T11:31:53+08:00">
                2014-08-28
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="../../../../categories/Web相关/" itemprop="url" rel="index">
                    <span itemprop="name">Web相关</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>  安装JDK(配置java环境)： 环境：CentOS6.5_x86-64bit 一、先安装JVM 1.使用7版本的jdk(到官网下载相应的软件包到本地<a href="http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jre-7u9-oth-JPR" target="_blank" rel="noopener">http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jre-7u9-oth-JPR</a>)</p>
<p>[root@localhost ~]# rpm -ivh jdk-7u9-linux-x64.rpm<br>Preparing… ########################################### [100%]<br>1:jdk ########################################### [100%]<br>Unpacking JAR files…<br>rt.jar…<br>Error: Could not open input file: /usr/java/jdk1.7.0_09/jre/lib/rt.pack<br>jsse.jar..<br>Error: Could not open input file: /usr/java/jdk1.7.0_09/jre/lib/jsse.pack<br>charsets.jar…<br>Error: Could not open input file: /usr/java/jdk1.7.0_09/jre/lib/charsets.pack<br>tools.jar…<br>Error: Could not open input file: /usr/java/jdk1.7.0_09/lib/tools.pack<br>localedata.jar…<br>Error: Could not open input file: /usr/java/jdk1.7.0_09/jre/lib/ext/localedata.pack</p>
<p>#-&gt;以上那些错误可以忽略，不影响jdk到安装和使用</p>
<p>2.安装后生成的文件：</p>
<p>[root@localhost ~]# cd /usr/java/<br>[root@localhost java]# ll<br>total 4<br>lrwxrwxrwx 1 root root 16 May 6 10:58 default -&gt; /usr/java/latest<br>drwxr-xr-x 10 root root 4096 May 6 10:58 jdk1.7.0_09<br>lrwxrwxrwx 1 root root 21 May 6 10:58 latest -&gt; /usr/java/jdk1.7.0_09</p>
<p>3.修改java环境变量：</p>
<p>[root@localhost ~]# vim /etc/profile.d/java.sh<br>export JAVA_HOME=/usr/java/latest<br>export PATH=$JAVA_HOME/bin:$PATH<br>[root@localhost ~]# . /etc/profile.d/java.sh</p>
<p>4.测试java环境是否可用.</p>
<p>[root@localhost java]# java -version<br>java version “1.7.0_09”<br>Java(TM) SE Runtime Environment (build 1. 7.0_09-b05)<br>Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)<br>[root@localhost java]#</p>
<p>此时只是部署好了java环境,而并非运行任何的JAVA程序,而Tomcat就是运行在这个环境上面的JAVA程序 二、安装配置tomcat 1.获取软件包并解压安装：</p>
<p>[root@localhost ~]# wget <a href="http://apache.fayea.com/apache-mirror/tomcat/tomcat-7/v7.0.55/bin/apache-tomcat-7.0.55.tar.gz" target="_blank" rel="noopener">http://apache.fayea.com/apache-mirror/tomcat/tomcat-7/v7.0.55/bin/apache-tomcat-7.0.55.tar.gz</a><br>[root@localhost ~]# tar -xf apache-tomcat-7.0.55.tar.gz -C /usr/local/<br>[root@localhost ~]# cd /usr/local/<br>[root@localhost local]# ln -sv apache-tomcat-7.0.5 tomcat<br>`tomcat’ -&gt; `apache-tomcat-7.0.55’<br>[root@localhost local]# cd tomcat/<br>[root@localhost tomcat]#</p>
<p>2.更改tomcat环境变量：</p>
<p>[root@localhost ~]# vim /etc/profile.d/tomcat.sh<br>export CATALINA_HOME=/usr/local/tomcat<br>export PATH=$CATALINA_HOME/bin/:$PATH<br>[root@localhost ~]# . /etc/profile.d/tomcat</p>
<p>3.启动tomcat</p>
<p>[root@localhost tomcat]# catalina.sh start</p>
<p>4.验证是否启动</p>
<p>[root@localhost tomcat]# ss -tunlp | grep java<br>tcp LISTEN 0 100 :::8080 :::<em> users:((“java”,25953,42))<br>tcp LISTEN 0 1 ::ffff:127.0.0.1:8005 :::</em> users:((“java”,25953,46))<br>tcp LISTEN 0 100 :::8009 :::* users:((“java”,25953,43))</p>
<p>#—&gt;注意三个端口，每一个单独的java程序都是由一个jvm来运行的.<br>[root@localhost tomcat]# jps<br>25953 Bootstrap #—&gt;这个进程是tomcat启动时为了实现其加速的一个程序.有这个进程则表示启动成功.<br>25995 Jps<br>[root@localhost tomcat]#</p>
<p>5.网页访问测试：<a href="http://IP:8080" target="_blank" rel="noopener">http://IP:8080</a> 现在tomcat已经启动了,注意上图中的三个按钮,后续说. <a href="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/wpid-d698a595a631e5b1f4c10780198b6dc9_c8b5d927-ed11-4825-ac80-c5f047b7c4a0.jpg" target="_blank" rel="noopener"><img src="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/wpid-d698a595a631e5b1f4c10780198b6dc9_c8b5d927-ed11-4825-ac80-c5f047b7c4a0-600x348.jpg" alt="wpid-d698a595a631e5b1f4c10780198b6dc9_c8b5d927-ed11-4825-ac80-c5f047b7c4a0.jpg"></a> 6.为了方便管理tomcat，为其提供SysV管理脚本.</p>
<p>[root@localhost ~]# vim /etc/rc.d/init.d/tomcat</p>
<p>#!/bin/sh<br># Tomcat init script for Linux.<br>#<br># chkconfig: 2345 96 14<br># description: The Apache Tomcat servlet/JSP container.<br>JAVA_HOME=/usr/java/latest<br>CATALINA_HOME=/usr/local/tomcat<br>export JAVA_HOME CATALINA_HOME<br>. /etc/init.d/functions</p>
<p>case $1 in<br>start)<br>  $CATALINA_HOME/bin/catalina.sh start &amp;&gt;/dev/null;;<br>stop)<br>  $CATALINA_HOME/bin/catalina.sh stop &amp;&gt;/dev/null;;<br>  restart)<br>$CATALINA_HOME/bin/catalina.sh stop &amp;&gt;/dev/null<br>  sleep 2<br>  $CATALINA_HOME/bin/catalina.sh start &amp;&gt;/dev/null;;<br>*)<br>  echo “Usage:`basename $0` {start|stop|restart}”<br>exit 1<br>;;<br>esac<br>[root@localhost ~]# chmod +X /etc/rc.d/init.d/tomcat<br>[root@localhost ~]# chkconfig –add tomcat</p>
<p>#-&gt;通过上面这个服务控制脚本就可以控制tomcat的启动、关闭等操作了;</p>
<p>7.Tomcat 配置文件配置层次： Tomcat是一个基于组件的服务器，它的构成组件都是可配置的，其中最外层的给件是CATALINA SERVLET容器，其他的组件按照一定的格式要求配置在这个顶层容器中。Tomcat的各个组件是server.xml文件中配置的，Tomcat服务器默认情况下对各种组件都有默认的实现，下面通过分析server.xml文件来理解Tomcat的各个组件是如何组织的。</p>
<server>    #—&gt;顶层组件，代表一个服务器<br>     <service>    #—&gt;顶层组件，是Connector的集合，将连接器关联至engine；因此一个service内部可以有多个connector，但只能有一个engine<br>          <connector>    #—&gt;连接器类组件，代表通信接口<br>          <engine>    #—&gt;容器类组件，为特定的Service组件处理所有客户请求，可包含多个Host<br>               <host>    #—&gt;为特定的虚拟主机处理所有客户请求<br>                    <context>    #—&gt;为特定的WEB应用处理所有客户请求<br>                    </context><br>               </host><br>               <host><br>               </host><br>          </engine><br>     </connector></service><br></server>

<p>详述这些组件： <strong>顶级组件：</strong>位于整个配置的顶层； <strong>容器类：</strong>可以包含其它组件的组件；<br>     engine: 核心容器，catalina引擎，负责通过connector接收用户请求,在一个engin内部可以有多个host<br>     host: 类似于httpd中的虚拟主机；支持基于FQDN的虚拟主机<br>     context: 最内层的容器类组件，一个context代表一个web应用程序；配置context的主要目的，指定对应的webapp的根目录；还能为webapp指定额外的属性，如部署方式等； <strong>连接器组件：</strong>连接用户请求至tomcat； 两类连接器： 1.基于HTTP 协议 2.基于AJP 二进制协议,使用httpd反向代理用户请求至tomcat时,在httpd和tomcat之间使用.被嵌套类的组件：位于一个容器当中，不能包含其它组件； <strong>被嵌套类的组件：</strong>位于一个容器当中，不能包含其它组件； valve: 拦截请求并在将其转至对应的webapp之前进行某种处理操作；可以用于任何容器中；<br>          access log valve:<br>          remote address filter value: 基于IP做访问控制<br>          logger: 日志记录器，用于记录组件 内部的状态信息(可用于除context之外的任何容器中)<br>          realm: 可以用于任何容器类的组件中，关联一个用户认证库，实现认证和授权；<br>          UserDatabaseRealm: 使用JNDI自定义的用户认证库；<br>          MemoryRealm: tomcat-users.xml中<br>          JDBCRealm: 基于JDBC连接至数据库中查找用户； <strong>部署:</strong>使用类加载器,为webapp准备好其依赖所有类. 8.服务端口说明： 在我们启动之后有3个端口：8005，8009，8080 <strong>8005</strong>  ==&gt;位于server顶级组件当中,它监听于本地&lt;127.0.0.1&gt; 通过这个port我们可以直接在本地关闭tomcat应用程序,以及java进程. 如下： (1)在本机安装telnet ; </p>
<p>[root@localhost ~]# yum install -y telnet</p>
<p>(2)连接本机8005port,发送”SHUTDOWN”指令</p>
<p>[root@localhost ~]# telnet localhost 8005  #–&gt;telnet本地8005port<br>Trying ::1…<br>telnet: connect to address ::1: Connection refused<br>Trying 127.0.0.1…<br>Connected to localhost.<br>Escape character is ‘^]‘.<br>SHUTDOWN     #–&gt;发送”SHUTDOWN”指令！<br>Connection closed by foreign host.<br>[root@node1 ~]# ss -tunlp | grep java  #–&gt;此时再去检查端口,显示没有,说明我们通过telnet已经发送指令将其关闭成功啦,危险系数较高,配置服务安全性时需注意！<br>[root@node1 ~]# service tomcat start   #–&gt;再次启动,检查端口正常否.<br>[root@node1 ~]# ss -tunlp | grep java<br>tcp    LISTEN     0      100                   :::8080                 :::<em>      users:((“java”,6430,42))<br>tcp    LISTEN     0      1       ::ffff:127.0.0.1:8005                 :::</em>      users:((“java”,6430,46))<br>tcp    LISTEN     0      100                   :::8009                 :::*      users:((“java”,6430,43))<br>[root@node1 ~]#</p>
<p><strong> 8009，8080  ==&gt;</strong>前面已说到了在连接器组件当中有个<connector>,他们在这个组件当中分别对应了两种协议. 8009   基于AJD协议 8080  基于http协议,当然在<connector>中可以添加各种参数,例如”address”等,默认配置文件中没有指定ip地址,默认就是监听所有.这个端口一般修改为80. 三、虚拟主机定义： (1)创建网页目录：</connector></connector></p>
<p>[root@node1 ~]# mkdir /www/webapps/ROOT</p>
<p>(2)创建网页测试文件:</p>
<p>[root@localhost ~]# vim /www/webapps/ROOT/index.jsp<br>&lt;%@ page language=”java” %&gt;<br>&lt;%@ page import=”java.util.*” %&gt;</p>
<html><br>  <head><meta name="generator" content="Hexo 3.8.0"><br>    <title>JSP test page.</title><br>  </head><br>  <body><br>    &lt;% out.println(“Hello,world!”); %&gt;<br>  </body><br></html>

<p>(3)修改配置文件如下：</p>
<p>[root@node1 ~]# vim /usr/local/tomcat/conf/server.xml<br>……<br>……<br>  <connector port="80" protocol="HTTP/1.1" connectiontimeout="20000" redirectport="8443"><br>…..<br>…..</connector></p>
<p><host name="www.aaa.com" appbase="/www/webapps" unpackwars="true" autodeploy="true"><br>             <context path="" docbase="ROOT" reloadable="true"><br>         <valve classname="org.apache.catalina.valves.AccessLogValve" directory="logs" #-="">日志保存格式<br>                        prefix=”<a href="http://www.aaa.www_log.&quot;" target="_blank" rel="noopener">www.aaa.www_log.&quot;</a> suffix=”.txt”<br>                        pattern=”%h %l %u %t &quot;%r&quot; %s %b” /&gt;<br></valve></context></host><br>……<br>……</p>
<p>(4)重启服务测试：</p>
<p>[root@localhost ~]# service tomcat restart</p>
<p><a href="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat.png" target="_blank" rel="noopener"><img src="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat.png" alt="tomcat"></a> 注意:此处我已经对该服务器做了解析. (5)虚拟主机的别名机制：</p>
<p>[root@node1 ~]# vim /usr/local/tomcat/conf/server.xml<br>……<br>……<br>  <connector port="80" protocol="HTTP/1.1" connectiontimeout="20000" redirectport="8443"><br>…..<br>…..</connector></p>
<p><host name="www.aaa.com" appbase="/www/webapps" unpackwars="true" autodeploy="true"><br>             <context path="" docbase="ROOT" reloadable="true"><br>             <context path="/bbs" docbase="/www/webapps/bbsapp" reloadable="true">  #—&gt;在原有虚拟主机中添加一个Context<br>         <valve classname="org.apache.catalina.valves.AccessLogValve" directory="logs" #-="">日志保存格式<br>                        prefix=”<a href="http://www.aaa.www_log.&quot;" target="_blank" rel="noopener">www.aaa.www_log.&quot;</a> suffix=”.txt”<br>                        pattern=”%h %l %u %t &quot;%r&quot; %s %b” /&gt;<br></valve></context></context></host><br>……</p>
<p>#—&gt;创建目录bbsapp<br>[root@localhost ~]# mkdir /www/webapps/bbsapp </p>
<p>#—&gt;创建测试文件<br>[root@localhost ~]# cp /www/webapps/ROOT/index.jsp /www/webapps/bbsapp/index.jsp</p>
<p>#—&gt;编辑测试文件,与上面的不同即可<br>[root@localhost ~]# vim /www/webapps/bbsapp/index.jsp</p>
<p>#—&gt;重启服务测试<br>[root@localhost ~]# service tomcat restart<br>[root@localhost ~]#<br>……</p>
<p><a href="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat1.png" target="_blank" rel="noopener"><img src="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat1.png" alt="tomcat"></a> 四、服务状态信息&amp;Dashboard: 在最前面的那种图片当中我们看到了tomcat服务的默认界面有三个按钮： <a href="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat2.png" target="_blank" rel="noopener"><img src="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat2.png" alt="tomcat"></a>   当我们点击”Server Status”时,需要身份验证： <a href="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat3.png" target="_blank" rel="noopener"><img src="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat3.png" alt="tomcat"></a> 点击”取消”,网页会提示我们如何去修改,并能够登录查看状态等信息. <a href="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat4.png" target="_blank" rel="noopener"><img src="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat4.png" alt="tomcat"></a>  那就去修改这个配置文件吧：</p>
<p>[root@localhost ~]# vim /usr/local/tomcat/conf/tomcat-users.xml<br>……<br>……</p>
<p><role rolename="manager-gui"></role></p>
<p><user username="tomcat" password="tomcat" roles="manager-gui"><br>……<br>……</user></p>
<p>#—&gt;重启服务<br>[root@varnish ~]# service tomcat restart</p>
<p>#—&gt;#测试：(这里只是状态界面,如果想看其他请看帮助信息)</p>
<p><a href="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat5.png" target="_blank" rel="noopener"><img src="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2014/08/tomcat5.png" alt="tomcat"></a></p>

      
    </div>
    
    
    
<div>
  
    <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>


  
</div>
    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="../../../../tags/Java/" rel="tag"># Java</a>
          
            <a href="../../../../tags/jdk/" rel="tag"># jdk</a>
          
            <a href="../../../../tags/tomcat/" rel="tag"># tomcat</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="../../27/snmp-e5-8d-8f-e8-ae-ae-e8-af-a6-e8-a7-a3/" rel="next" title="Snmp协议详解">
                <i class="fa fa-chevron-left"></i> Snmp协议详解
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="../../../10/31/lvskeepalived/" rel="prev" title="LVS+Keepalived">
                LVS+Keepalived <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/myphoto.png"
                alt="OutMan" />
            
              <p class="site-author-name" itemprop="name">OutMan</p>
              <p class="site-description motion-element" itemprop="description">😊</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="../../../../archives/">
              
                  <span class="site-state-item-count">79</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="../../../../categories/index.html">
                  <span class="site-state-item-count">22</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="../../../../tags/index.html">
                  <span class="site-state-item-count">46</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/guomaoqiu" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i></a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:guomaoqiu@google.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i></a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">OutMan</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="../../../../lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="../../../../js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="../../../../js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="../../../../js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="../../../../js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="../../../../js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="../../../../js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="../../../../js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
